package cn.edu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

@Controller
public class FileController {

    @RequestMapping("/upload")
    public String upload(String name, MultipartFile uploadFile, HttpServletRequest request) throws IOException {
        System.out.println(request.getServletContext().getRealPath("upload"));
        //获取上传文件的名称
        String fileStr = uploadFile.getOriginalFilename();
        //执行数据的传输
        uploadFile.transferTo(new File("c:/test/"+fileStr));
        return "success";
    }

}
